package com.sy.musicapp.intent.network

import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

object ServiceCreator {
    //            private const val Base_Url = "http://192.168.23.234:5000/"
    private const val Base_Url =
        "https://1926381012550513.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/test.LATEST/netease_cloud/"

    private val okHttpClient = OkHttpClient()
        .newBuilder()
        .addInterceptor(OkHttpSendInterceptor())
        .addInterceptor(OkHttpReceiveInterceptor())
        .retryOnConnectionFailure(true)

    private val retrofit = Retrofit.Builder()
        .baseUrl(Base_Url)
        .client(okHttpClient.build())
        .addConverterFactory(GsonConverterFactory.create())
        .build()


    fun <T> create(serviceClass: Class<T>): T = retrofit.create(serviceClass)

    inline fun <reified T> create(): T = create(T::class.java)

}